package com.sl.mes.app.controller;

import com.sl.mes.app.dao.agg.AggTeamBVo;
import com.sl.mes.db.itf.org.IBdPsnDoc;
import com.sl.mes.db.itf.team.IEwmTeam;
import com.sl.mes.db.itf.team.IEwmTeamB;
import com.sl.mes.db.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/mes/team")
@Validated
public class MesTeamController {
    @Autowired
    private IBdPsnDoc iBdPsnDocService;
    @Resource
    private IEwmTeamB iEwmTeamBService;

    /**
     * 根据pk_team_b查询人员的班组信息
     * @param pk_team_b
     * @return
     */
    @PostMapping("/queryUserTeam")
    public AggTeamBVo queryUserTeam(String pk_team_b){
        AggTeamBVo aggTeamVo=new AggTeamBVo();
        if(iEwmTeamBService.findById(pk_team_b)!=null){
            EwmTeamB ewmTeamB = iEwmTeamBService.findById(pk_team_b);
            aggTeamVo.setEwmTeamB(ewmTeamB);
            List<BdPsndoc> lstPsnDoc = iBdPsnDocService.getPsnByPsnId(ewmTeamB.getPkPsn());
            aggTeamVo.setBdPsndocLst(lstPsnDoc);
        }
        return aggTeamVo;
    }
//    @PostMapping("/query")
//    public
}
